package com.foreverwin.mes.production.service.impl;

import com.foreverwin.mes.core.base.FrontPage;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.foreverwin.mes.production.model.CleanData;
import com.foreverwin.mes.production.mapper.CleanDataMapper;
import com.foreverwin.mes.production.model.Station;
import com.foreverwin.mes.production.service.CleanDataService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
 * <p>
 * 清洁主数据 服务实现类
 * </p>
 *
 * @author Max
 * @since 2020-02-11
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class CleanDataServiceImpl extends ServiceImpl<CleanDataMapper, CleanData> implements CleanDataService {


    @Autowired
    private CleanDataMapper cleanDataMapper;

    @Override
    public Page<CleanData> selectPage(FrontPage<CleanData> frontPage, CleanData cleanData) {
        EntityWrapper<CleanData> queryWrapper = new EntityWrapper<>();
        queryWrapper.setEntity(cleanData);
        return super.selectPage(frontPage.getPagePlus(), queryWrapper);
    }

    @Override
    public List<CleanData> selectList(CleanData cleanData) {
        EntityWrapper<CleanData> queryWrapper = new EntityWrapper<>();
        queryWrapper.setEntity(cleanData);
        return super.selectList(queryWrapper);
    }

    /**
     * 查询清洁数据是否存在
     *
     * @param site
     * @param workCenter
     */
    @Override
    public CleanData getCleanData(String site, String workCenter,String cleanName) {
        CleanData cleanDataModel = new CleanData();
        cleanDataModel.setSite(site);
        cleanDataModel.setWokeCenter(workCenter);
        cleanDataModel.setCleanName(cleanName);
        return cleanDataMapper.selectOne(cleanDataModel);
    }


}